We all know that data validation is a very useful feature in Excel. You can use data validation to create a drop-down list in a cell and limit the values user can enter. But, do you know that you can use data validation in a multitude of ways to prevent users from entering wrong data?
Here is a practical application: Prevent users from entering duplicate values in a range of cells.
For eg. you are making an invoice. Wouldn’t it be cool if Excel prompted you when you enter a duplicate line item so that increase the item quantity instead of repeating it.
Here is a 3 step tutorial to do just that.
Step 1: Identify the range of cells where you want only unique values to be entered
This is simple. All you have to do is find the range where you want to control the user input. Lets say the range is B4:B11
Step 2: Set up Data Validation to prevent duplicate entries
Select the range (B4:B11) and go to data validation (Excel 2007: Data Ribbon > Data Validation, or press ALT+AVV)
Now, specify the validation type as “Custom”, this will allow us to use formulas to check for valid data. In our case, we need check if a particular entry is duplicated in the range B4:B11. This can be easily done using COUNTIF formula [learn COUNTIF Formula in plain English].
Go to the formula field and type the countif formula like this: =COUNTIF($B$4:$B$11,B4)<=1
Also, you can set up the “Error Alert” so that you can show a custom message when a duplicate value is typed, like “You have already added that product” message.

Once you set up error message, it will show up like this:

Step 3: Sit back and Relax
The third step is all too familiar. Now that you have prevented duplicate entries in your spreadsheets you can sit back and relax. May be read a few more spreadcheats.
More kickass stuff on data validation (and working with duplicates) using excel
There are a ton of useful articles on the site related to data validation and working with duplicates using excel. Here is a sample. Get started and learn something useful today.
- Data Validation Tricks in Excel [with downloadable tutorial]
- Remove Duplicate Values from a Range in Excel
- Using Array formulas to find if a list has duplicates
- Working with duplicate items in Excel [several examples]
- Examples & Articles on Excel Data Validation
This post is part of our spreadcheats series (yes, the series is still going after one year 😛 )













11 Responses to “Who is the most consistent seller? [BYOD]”
The Date column in the sample file is Text not Dates
[…] http://chandoo.org/wp/2015/02/18/calculating-consistency-in-excel/?utm_source=feedburner&utm_med… […]
Great Chandoo. Keep it up, Looking forward more from BYOD..
Thanks
With Excel 2013 the pivot table could be connected to the data model which provides a distinct count.
This will do for invoice count
=COUNTIF(F:F,H12)
Instead of
=COUNTIFS(sales[SELLER],$H12)
Excellent document. How did you make the last graphic? Witch app. Thanks for answer.
Can someone tell me what =countif(sales[date],sales[date]) is counting? The value is 19. Its found in the =SUMPRODUCT(IF(sales[SELLER]=H12,1/COUNTIFS(sales[SELLER],H12,sales[date],sales[date]),0))
Hi Chris,
=countif(sales [date],sales[date]) function is counting the unique dates in the table.
Vândalo
Excellent document!
Can you explain more about the calculation on Weighted consistency? More specific the small number is 0,00001 ?
How come the number should be smaller if there is more sellers?
Hi,
Not understood this formula: {=SUMPRODUCT(IF(sales[SELLER]=H12,1/COUNTIFS(sales[SELLER],H12,sales[date],sales[date]),0))}
Please explain.
Thanks.